const NUM_DIGIT_MAP: [char; 16] = [
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
];

pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let left_pos = num_str.find("(").unwrap();
    let right_pos = num_str.find(")").unwrap();
    let num = &num_str[..left_pos];
    let from_base = &num_str[left_pos + 1..right_pos].parse::<u32>().unwrap();
    let mut ten_base_num = 0;
    for (i, digit) in num.chars().rev().enumerate() {
        let digit = digit.to_digit(*from_base).unwrap();
        ten_base_num += digit * (from_base.pow(i as u32));
    }
    let mut result = String::new();
    while ten_base_num > 0 {
        let digit = NUM_DIGIT_MAP[(ten_base_num % to_base) as usize];
        result.push(digit);
        ten_base_num /= to_base;
    }
    result.chars().rev().collect::<String>()
}
